]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/MainShip.cs
Moves to ActorManager arch + Actor Inherited stuff
[rbdr/super-polarity] / Super Polarity / MainShip.cs
index 51d1eb306126e8c7c17141245586e1cf9509969d..92ccab798fff4d3b6206e8f0e43d7bc8e2c7f583 100644 (file)
@@ -3,47 +3,64 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content;
 using Microsoft.Xna.Framework.Graphics;
 
 namespace SuperPolarity
 {
-    class MainShip
+    class MainShip : Ship
     {
-        public Texture2D PlayerTexture;
-        public Vector2 Position;
-        public bool Active;
-        public int Lives;
-        public int Multiplier;
-        public int Score;
-        public float Angle;
-
-        public int Width
+        
+        uint Multiplier;
+        uint Lives;
+        uint Score;
+        ParticleEngine particleEngine;
+
+        public override void Initialize(ContentManager Content, Texture2D texture, Vector2 position)
+        {
+            base.Initialize(Content, texture, position);
+
+            Multiplier = 1;
+            Lives = 3;
+            Score = 0;
+
+            List<Texture2D> texturesList = new List<Texture2D>();
+            texturesList.Add(Content.Load<Texture2D>("Graphics\\circle"));
+            texturesList.Add(Content.Load<Texture2D>("Graphics\\diamond"));
+            texturesList.Add(Content.Load<Texture2D>("Graphics\\star"));
+
+            particleEngine = new ParticleEngine(texturesList, Position);
+
+            BindInput();
+        }
+
+        void BindInput()
         {
-            get { return PlayerTexture.Width; }
+            InputController.Bind("moveX", HandleHorizontalMovement);
+            InputController.Bind("moveY", HandleVerticalMovement);
         }
 
-        public int Height
+        public void HandleHorizontalMovement(float value)
         {
-            get { return PlayerTexture.Height; }
+            Acceleration.X = value * AccelerationRate;
         }
 
-        public void Initialize(Texture2D texture, Vector2 position)
+        public void HandleVerticalMovement(float value)
         {
-            PlayerTexture = texture;
-            Position = position;
-            Active = true;
-            Multiplier = 1;
-            Lives = 3;
-            Score = 0;
+            Acceleration.Y = value * AccelerationRate;
         }
 
-        public void Update()
+        public override void Update(GameTime gameTime)
         {
+            base.Update(gameTime);
+            particleEngine.EmitterLocation = Position;
+            particleEngine.Update();
         }
 
-        public void Draw(SpriteBatch spriteBatch)
+        public override void Draw(SpriteBatch spriteBatch)
         {
-            spriteBatch.Draw(PlayerTexture, Position, null, Color.White, Angle, Vector2.Zero, 1f, SpriteEffects.None, 0f);
+            particleEngine.Draw(spriteBatch);
+            base.Draw(spriteBatch);
         }
     }
 }